package com.example.demo.controller;

import com.example.demo.entity.Dupnew;
import com.example.demo.service.DupnewService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Dupnew)表控制层
 *
 * @author makejava
 * @since 2022-02-15 14:04:37
 */
@RestController
@RequestMapping("dupnew")
public class DupnewController {
    /**
     * 服务对象
     */
    @Resource
    private DupnewService dupnewService;



    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<Dupnew> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.dupnewService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param dupnew 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Dupnew> add(Dupnew dupnew) {
        return ResponseEntity.ok(this.dupnewService.insert(dupnew));
    }

    /**
     * 编辑数据
     *
     * @param dupnew 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<Dupnew> edit(Dupnew dupnew) {
        return ResponseEntity.ok(this.dupnewService.update(dupnew));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.dupnewService.deleteById(id));
    }

}

